﻿using System.IO;
using System.Linq;
using System.Windows.Forms;

namespace Controler
{
    public class ImgPreview
    {
        public int CurrentIndex { get; set; }
        public void ToShow(string[] imgs, PictureBox[] pics, Label[] labs)
        {
            var picCnt = pics.Count();

            var imgShowed = imgs.ToList().OrderByDescending(x => x).Skip(CurrentIndex).Take(picCnt).ToList();

            var imgCnt = imgShowed.Count();
            for (int i = 0; i < imgCnt; i++)
            {
                pics[i].ImageLocation = imgShowed[i];
                labs[i].Text = Path.GetFileNameWithoutExtension(imgShowed[i]);
            }

            for (int i = 0; i < picCnt - imgCnt; i++)
            {
                pics[pics.Count() - i - 1].ImageLocation = "";
                labs[pics.Count() - i - 1].Text = "";
            }
        }
    }
}
